<!-- orders 页面内容 -->
<section class="orders col-xs-12 padding-reset" ng-controller="ordersCtrl">
    <div class="panel panel-default">
        <!-- active 是当前列表的分类状态 -->
        <div class="panel-heading handerbtn">
            <button type='button' class="btn panel-heading-btn yf-shadow" ng-class="{'active': !ishistory}" ng-click="setType(false);getOrders(1);setHistroy(false);" ng-if="!mobile">进行中</button>
            <button type='button' class="btn panel-heading-btn yf-shadow" ng-class="{'active': ishistory}" ng-click="setType(true);getOrders(1);setHistroy(true);" ng-if="!mobile">历史订单</button>
         
            <div class="row margin-reset search-input">
                <button down-file="web/orders" down-file-type="xlsx" now-token="nowToken" search-data='daoDate' class="pull-right export">导出</button>
                <button class="pull-right" data-toggle="modal" data-target="#search-modal"><i class="icon-search"></i>订单搜索</button>
            </div>
        
            <!--<div class="row margin-reset row-income ">
                <h5 class="title-income-info" ng-if="user_role == 2">预计可收入总额 <span class="title-income pull-right">￥{{ user.total | moneyint }}</span></h5>
            </div>-->

            <div class="row margin-reset row-income " ng-if="!!user.company_id && user.user_type != 'manager'">
                <div class="col-md-6 col-sm-12 col-xs-10">预计提成总金额: <span class="title-income">￥{{ user.sale_commission_count | moneyint:true }}</span></div>
                <div class="col-md-6 col-sm-12 col-xs-10">介绍人提成总金额: <span class="title-income">￥{{ user.intro_commission_count | moneyint:true }}</span></div>
            </div>
        </div>
        <empty data='orders'></empty>
        <ul class="list-group">
            <li class="list-group-item yf-shadow" ng-repeat='order in orders track by $index'>
                <order-label state='order.mount_order'></order-label>
                <!-- <div ui-sref="mine.orderdetail({ id: order.id, time: order.booking_date })" style="cursor: pointer;"> -->
                <div ui-sref="orderDetail({id: order.id})" style="cursor: pointer;">
                    <div class="row">
                        <div class="col-md-7 col-sm-7 col-xs-7 time">
                            订单号: {{ order.serial_number }}
                        </div>
                        <div class="col-md-5 col-sm-5 col-xs-5 text-right state">
                            <span ng-bind='order.workflow_state | state'></span>
                        </div>
                    </div>
                    <div class="row">
                    		<div class="col-md-13 col-sm-13 col-xs-13 text-right" style="color: #e1e1e1;" ng-if="(user.user_type == 'manager' || user.id == order.customer_id) && ['new', 'appointed_measurement', 'measured'].indexOf(order.workflow_state) == -1 && !!order.service_info.name">指派给-{{ order.service_info.name }}</div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 col-sm-12" ng-if='!order.mount_order'>
                            测量时间: <span class="name" ng-bind='order.booking_date * 1000 | date:"yyyy-MM-dd HH:mm"'></span>
                        </div>
                        <div class="col-md-12 col-sm-12" ng-if='order.mount_order'>
                            安装时间: <span class="name" ng-bind='order.install_date * 1000 | date:"yyyy-MM-dd HH:mm"'></span>
                        </div>
                    </div>
                    <div class="row" ng-if="user_role == 2">
                        <div class="col-md-12 col-sm-12">
                            预计本单收入: <span class="income">￥{{ order.total | moneyint }}</span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 col-sm-12">
                            真实姓名: <span class="name">{{ order.name }}</span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12 col-sm-12 info">
                            预估面积: {{order.square}}(㎡) | 品牌: {{order.company_name}}
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6 col-sm-6 col-xs-12 address">
                        <span class="glyphicon glyphicon-map-marker"></span>
                        <a ng-bind='order.address' ng-class="{'dis': user_role != 2}" ng-click="goMap(user_role, order.id);"></a>
                    </div>
                    <div class="col-md-6 col-sm-6 col-xs-12 action-btns" ng-if="['completed', 'canceled'].indexOf(order.workflow_state) == -1">
                        <a type='button' class="c1" data-toggle="modal" data-target=".bs-example-modal-sm" ng-click="readyOrder(order, $index);" ng-if='user.id == order.customer_id && ["new", "appointed_measurement"].indexOf(order.workflow_state) != -1'>编辑</a>
                        <a href="" type='button' class="c1" ng-if="['new', 'appointed_measurement', 'measured'].indexOf(order.workflow_state) != -1" ng-click="deleteOrder(order.id, $index);">取消</a>
                    </div>
                    <div class="col-md-6 col-sm-6 col-xs-12 action-btns" ng-if="order.workflow_state == 'completed' && user_role == 2">
                        {{ order.server_info.rate }}
                        <span>系统默认好评</span>
                    </div>
                </div>
            </li>
        </ul>
        <nav ng-show='orders && orders.length > 0 && page.total_count > page.current_total && !iskeyword' style="text-align: center;">
            <ul uib-pagination total-items="page.total_count" items-per-page='page.current_total' ng-model="page.current_page" ng-change="updateUrlPage(page.current_page);" max-size="maxSize" class="pagination-sm" boundary-links="true" force-ellipses="true" next-text="下一页" last-text="尾页" previous-text="上一页" first-text="首页"></ul>
        </nav>
    </div>
    <div class="modal fade bs-example-modal-sm" id='myModal' tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm modal-edit">
            <div class="modal-content">
                <form name='modalorderform' role="form" novalidate autocomplete="false" ng-submit="putOrder(modalorderform.$invalid, readyorder);">
                    <div class="form-group">
                        <label for="time">预约时间</label>
                        <button type="button" class="close" data-dismiss='modal'><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        <input class="orderflatpickr form-control" id='orderflatpickr' type="text" placeholder="预约时间" required>
                    </div>
                    <div class="form-group">
                        <label for="person">预约人</label>
                        <input type="text" class="form-control" ng-model='readyorder.name' ng-pattern="/^[A-Za-z0-9\u4e00-\u9fa5]{2,20}$/" name="person" placeholder="预约人" required>
                    </div>
                    <div class="form-group error-container" ng-show="ismodalorderform && (modalorderform.person.$error.pattern || modalorderform.person.$error.required)">
                        请输入长度 2-20位的名字(中文，字母，数字组成)！
                    </div>
                    <div class="form-group">
                        <label for="tel">联系电话</label>
                        <input type="tel" class="form-control" ng-model='readyorder.tel' ng-pattern="/^1[34578]\d{9}$/" name="tel" placeholder="联系电话" required>
                    </div>
                    <div class="form-group error-container" ng-show="ismodalorderform && (modalorderform.tel.$error.pattern || modalorderform.tel.$error.required)">
                        请输入有效手机号！
                    </div>
                    <div class="row">
                        <div class="text-center">
                            <button type="submit" class="btn btn-default btn-submit yf-btn">保存修改</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="modal fade common-modal" id="search-modal" tabindex="-1" role="dialog" aria-labelledby="common-modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content yf-shadow">
                <div class="modal-header text-center">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h3 class="modal-title" id="common-modal">
                          订单搜索
                        </h3>
                </div>
                <div class="modal-body">
                  <div class="row">
                      <div class="form-group col-lg-offset-1 col-md-offset-1 col-sm-offset-1 col-lg-10 col-md-10 col-sm-10 col-xs-12">
                          <label for="">起止时间</label>
                          <input type="text" class="form-control startTime mt_input" id="start-date" placeholder="请选择开始时间">
                          <input type="text" class="form-control endTime mt_input" id="start-date" disabled placeholder="请结束开始时间">
                      </div>
                      <div class="form-group col-lg-offset-1 col-md-offset-1 col-sm-offset-1 col-lg-10 col-md-10 col-sm-10 col-xs-12">
                          <label for="">订单状态</label>
                          <select class="form-control mt_input" ng-model='search_state' ng-options="statesArr.name for statesArr in statesArrs" required>
                              <option value="" selected>订单状态</option>
                          </select>
                      </div>
                      <div class="form-group col-lg-offset-1 col-md-offset-1 col-sm-offset-1 col-lg-10 col-md-10 col-sm-10 col-xs-12">
                          <label for="">关键字搜索</label>
                          <input type="text" class="form-control mt_input" id="order-num" ng-model='q' placeholder="订单号、服务商名称、品牌商名称、省市区、渠道">
                      </div>
                      <div class="col-lg-offset-1 col-md-offset-1 col-sm-offset-1 col-lg-10 col-md-10 col-sm-10 col-xs-12">
                          <button type="submit" class="btn btn-block mt_group_btn" ng-click="searchOrder();">确认搜索</button>
                      </div>
                  </div>
                </div>
            </div>
        </div>
    </div>
</section>
